class Solution:
    def maxSumDivThree(self, nums: list) -> int:
        seen = [0, 0, 0]
        for i in nums:
            for j in seen[:]:
                seen[(i + j) % 3] = max(seen[(i + j) % 3], i + j)

        return seen[0]
